<!-- 检查记录 -->
<template>
  <el-dialog title="检查记录" :close-on-click-modal="false" fullscreen :visible.sync="visible" center>
    <el-button class="miui-dialog-close-btn" @click="visible = false">关闭页面</el-button>
    <div class="avue-crud">
      <el-table :data="dataList" border v-loading="Loading">
        <el-table-column label="检查时间">
          <template slot-scope="scope">
            <el-button type="text" @click="getRecordDetail(scope.row)">{{scope.row.checkDate}}</el-button>
          </template>
        </el-table-column>
        <el-table-column label="检查类型">
          <template slot-scope="scope">
            <el-button type="text" @click="getRecordDetail(scope.row)">{{scope.row.logoFlag}}</el-button>
          </template>
        </el-table-column>
        <el-table-column label="姓名">
          <template slot-scope="scope">
            <el-button type="text" @click="getRecordDetail(scope.row)">{{scope.row.name}}</el-button>
          </template>
        </el-table-column>
        <el-table-column label="就诊卡号">
          <template slot-scope="scope">
            <el-button type="text" @click="getRecordDetail(scope.row)">{{scope.row.cardNum}}</el-button>
          </template>
        </el-table-column>
        <el-table-column prop="fullName" label="班级信息">
          <template slot-scope="scope">
            <el-button type="text" @click="getRecordDetail(scope.row)">{{scope.row.fullName}}</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <jiao-su v-if="oneVisible" ref="oneDialog"></jiao-su>
    <qu-guang v-if="twoVisible" ref="twoDialog"></qu-guang>
    <jian-ce v-if="threeVisible" ref="threeDialog"></jian-ce>
  </el-dialog>
</template>

<script>
  import { mapGetters } from "vuex";
  import { getRecordListByPersonId } from '@/api/pvm/person'

  import JiaoSu from '@/views/pvm/ckCorneal/form'
  import QuGuang from '@/views/pvm/arcoptometry/form'
  import JianCe from '@/views/pvm/checkdata/checkdata-form'

  export default {
    data() {
      return {
        visible: false,
        oneVisible: false,
        twoVisible: false,
        threeVisible: false,
        personId: '',
        dataForm: {
          key: ""
        },
        dataList: [],
        Loading: false
      };
    },
    components: {
      JiaoSu,
      QuGuang,
      JianCe
    },
    computed: {
      ...mapGetters(["permissions"])
    },
    methods: {
      // 初始化数据
      init(data) {
        this.visible = true
        this.personId = data.id
        this.$nextTick(() => {
          this.getDataList()
        })
      },
      // 获取数据列表
      getDataList() {
        this.Loading = true;
        getRecordListByPersonId(this.personId).then(response => {
          if(response.data.code == '0'){
            this.dataList = response.data.data
          }else{
            this.$message.error(response.data.msg)
          }
          this.Loading = false
        })
      },
      // 查看档案详情
      getRecordDetail(data){
        if(data.logoFlag == '屈光档案'){
          this.twoVisible = true
          this.$nextTick(() => {
            this.$refs.twoDialog.init('edit', data.id, '三维检查', data.docId)
          })
        }else if(data.logoFlag == '近视监测'){
          this.threeVisible = true
          this.$nextTick(() => {
            this.$refs.threeDialog.init(data.id)
          })
        }else if(data.logoFlag == '角膜复查'){
         this.oneVisible = true
         this.$nextTick(() => {
           this.$refs.oneDialog.init(data.checkType, data.id, '常规检查', data.docId)
         })
        }
      }
    }
  }
</script>
